<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <title>Insert title here</title>

  <link rel="stylesheet" href="css/appvoralCSS.css">
  <link rel="stylesheet" href="css/ui-dialog.css">
  <link rel="stylesheet" href="css/fontello.css">
  <link rel="stylesheet" href="css/selector.css">
  <script type="text/javascript" src="js/jquery.js"></script>
  <script type="text/javascript" src="js/dialogmin.js"></script>
  <script type="text/javascript" src="js/sea.js"></script>
  <script type="text/javascript" src="js/selector.js"></script>
  <style>
    ::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }

    ::-webkit-scrollbar-thumb {
      border-radius: 10px;
      background: #b1d8ff;
    }

    ::-webkit-scrollbar-track {
      border-radius: 10px;
      background: #e6e6e6;
    }

    #remark .submitOk {
      display: inline-block;
      margin-top: 4px;
    }
  </style>
</head>

<body>
  <div id="auditInfo"></div>
  <!--<div>1236</div>-->
</body>
<script type="text/javascript">
  // var ctxPath = '../../laboratory'
  // var processinsId = null;
  var closeDailog = false;
  // var processinsId = getUrlField('processinsId');
  var id = getUrlField('id');
  var templateKey = getUrlField('templateKey');
  var baseUrl = getUrlField('baseUrl');
  var ticket = getUrlField('ticket');
  var flowType = getUrlField('flowType')
  $(function () {
    //默认显示工作流面板
    window.parent.postMessage({
      cmd: 'loadSure',
      params: {}
    }, '*')
  })
  //赋值HTML展示流程图
  function setFlowHtml(data) {
    try {
      $("#auditInfo").html(data)
    } catch (error) {
      console.log(error);
    }
  }
  // var path = baseUrl;
  // var url = path + "/workflow/getView.htm";
  // if (!templateKey || !ticket) {
  //   url = path + "/workflow/getView.htm";
  // }
  // var data = {
  //   "auditId": id,
  //   // "templateKey": templateKey,
  //   // "ticket": ticket
  // }
  // $.ajax({
  //   type: "get",
  //   headers: {
  //     "Content-Type": "application/json; charset=utf-8"
  //   },
  //   url: url,
  //   dataType: "html",
  //   data: JSON.stringify(data),
  //   data: data,
  //   success: function (reponseData) {
  //     // var data1 = reponse;
  //     $("#auditInfo").html(reponseData);
  //     $(".approval-content > ._showbutton").click()
  //     // }, '*');
  //   },
  //   error: function (e) {
  //   }

  // });

  // 这下面的click方法，都是做高度自适应用的
  $("#workflowsvg").click(function () {
    setTimeout(function () {
      // workflow.sendHeight($('#auditInfo').height())
      sendFlowHeight($('#auditInfo').height())
    }, 500)
  });
  $(".approval-history").on("click", ".icon-check-empty", function () {
    setTimeout(function () {
      // workflow.sendHeight($('#auditInfo').height())
      sendFlowHeight($('#auditInfo').height())
    }, 500)
  });
  $(".approval-content > ._showbutton").click(function () {
    // workflow.sendHeight($('#auditInfo').height())
    sendFlowHeight($('#auditInfo').height())
  });

  function sendFlowHeight(height) {
    window.parent.postMessage({
      cmd: 'height',
      params: {
        height: h
      }
    }, '*')
  }
  function getDa() {

  }
  function approve(data) {
    console.log(data);
    // console.log(data)
    // let {
    //   __operation,
    //   __subinfo,
    //   __comment,
    //   taskid,
    //   __subuser
    // } = data;
    let taskId = data.taskId
    let processCode = data.processCode
    let setCode = data.setCode
    let comment = data.comment
    let operation = data.operation



    var param = {
      taskId:taskId,
      processCode: processCode,
      comment: comment,
      setCode: setCode,
      operation: operation
    }
    if(data.rejectNodeCode) param.rejectNodeCode = data.rejectNodeCode
    // if (flowType == 5 || flowType == 6) {
    // 主页面进行提交请求，避免不出现loading现象
    window.parent.postMessage({
      cmd: 'callBackSubmit',
      params: {
        data: param,
        msg: 'goSubmit'
      }
    }, '*');
    return;
  }
  function basePath() {
    //获取当前网址，如： http://localhost:8080/ems/Pages/Basic/Person.jsp
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： /ems/Pages/Basic/Person.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    //获取主机地址，如： http://localhost:8080
    var localhostPath = curWwwPath.substring(0, pos);
    //获取带"/"的项目名，如：/ems
    var basePath = localhostPath + "/";
    // basePath=process.env.baseUrl;
    return basePath;
  };

  String.prototype.replaceAll = function (reallyDo, replaceWith, ignoreCase) {
    if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
      return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith);
    } else {
      return this.replace(reallyDo, replaceWith);
    }
  }

  function getUrlField(field) {
    return getFieldByUrl(window.location.search, field);
  }
  //获取url地址后面的参数
  function getFieldByUrl(url, field) {
    var reg = new RegExp("(^|&|\\?)" + field + "=([^&]*)(&|$)", "i");
    var r = url.substr(1).match(reg);
    if (r != null)
      return decodeURI(r[2]);
    return "";
  };


</script>

</html>
